<?php
/**
 * polwebgis
 * 
 * This file is part of polwebgis.
 *
 * @copyright   Copyright (c) 2012 Dominik Janisch (http://www.joanneum.at)
 * @lastmodified    $LastChangedDate: 2012-03-07 09:15:12 +0000 (Wed, 07 Mar 2012) $
 * @revision    $Revision: 160 $ 
 */

class MapLayer
{
    protected $map_list_;
    
    const BORDER_COLOR = 'FFFFFF';
    
    const CLASS_BASE_COLOR = 'CCCCCC';
    
    const LAYER_OPACITY = 100;
    
    const MAP_FONTSIZE_LABEL_MAX = 30;
    
    const MAP_FONTSIZE_LABEL_DEFAULT = 10;

    public function __construct(&$map_list)
    {
        $this->map_list_ = $map_list;
    }
    
    public function __destruct(){}
    
    public function setLayerDefaultValues()
    {
        if($this->map_list_->get('base_color') === false)            
            $this->map_list_->set('base_color', constant("self::CLASS_BASE_COLOR"));
        if($this->map_list_->get('layer_opacity') === false)
            $this->map_list_->set('layer_opacity', constant("self::LAYER_OPACITY"));
        if($this->map_list_->get('border_color') === false)
            $this->map_list_->set('border_color', constant("self::BORDER_COLOR"));
        if($this->map_list_->get('map_fontsize_label') === false)
            $this->map_list_->set('map_fontsize_label', constant("self::MAP_FONTSIZE_LABEL_DEFAULT"));
    }
    
    public function checkLayerInput($request)
    {
        if($request->issetParameter('post', 'layer_opacity'))
        {
            $layer_opacity = (int)$request->getParameter('post', 'layer_opacity')>=0 && (int)$request->getParameter('post', 'layer_opacity')<=constant("self::LAYER_OPACITY") ? (int)$request->getParameter('post', 'layer_opacity') : constant("self::LAYER_OPACITY");
            $this->map_list_->set('layer_opacity', $layer_opacity);
        }
        if($request->issetParameter('post', 'map_fontsize_label'))
        {
            $map_fontsize_label = (int)$request->getParameter('post', 'map_fontsize_label')>=1 && (int)$request->getParameter('post', 'map_fontsize_label')<=constant("self::MAP_FONTSIZE_LABEL_MAX") ? (int)$request->getParameter('post', 'map_fontsize_label') : constant("self::MAP_FONTSIZE_LABEL_DEFAULT");
            $this->map_list_->set('map_fontsize_label', $map_fontsize_label);
        }
    }
}
?>
